//
//  RightMenuFootView.m
//  NOAHWM
//
//  Created by Frank on 6/26/13.
//  Copyright (c) 2013 Ryan. All rights reserved.
//

#import "RightMenuFootView.h"
#import "NYMemberCenterDataManager.h"

@implementation RightMenuFootView

@synthesize finaView;
@synthesize finaButton;
@synthesize serviceButton;
@synthesize serviecSheet;
@synthesize fpSheet;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)awakeFromNib
{
    serviecSheet  = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拨打客服热线" otherButtonTitles:nil, nil];
    fpSheet  = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拨打专属理财师电话" otherButtonTitles:nil, nil];
    if (!IsiPhone5()) {
        CGRect frame = self.frame;
        frame.size.height -= 88;
        self.frame = frame;        
    }
}


- (void)dealloc
{
    [finaView release];
    [finaButton release];
    [serviceButton release];
    [serviecSheet release];
    [fpSheet release];
    [super dealloc];
}

- (IBAction)serviceButtonPressed:(id)sender {
    [self.serviecSheet showInView:self];
}

- (IBAction)finaButtonPressed:(id)sender {
    [self.fpSheet showInView:self];
}

#pragma mark - UIActionSheetDelegate methods
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(actionSheet==self.fpSheet&&buttonIndex == 0)
    {
        NSURL *target = [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"tel:%@", [NYMemberCenterDataManager sharedManager].loginMember.fp_mobile]] autorelease];
        [[UIApplication sharedApplication] openURL:target];
    }
    else if(actionSheet==self.serviecSheet&&buttonIndex == 0)
    {
        NSURL *target = [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"tel:%@", [NYMemberCenterDataManager sharedManager].loginMember.custom_service_phone]] autorelease];
        [[UIApplication sharedApplication] openURL:target];
    }
}

@end
